Well-Formed and Valid

There are two issues that we are going to address in this chapter:

The creation of well-formed documents

The creation of valid documents.

“Well-formed” and “valid” are often the most misunderstood words among all of the terminology relating to XML.  In this chapter, we are going to discuss what these terms relate to, how you can check to make sure that your documents are both well-formed and valid.  Before we get started, let’s put a high-level definition to these terms as they relate to XML.  

A well-formed document is one that is syntactically correct.  It’s elements and attributes are correct as to their declaration.

A valid document is one whose content is correct.  The values contained within elements and attributes adhere to their respective element and attribute declarations.

In a nutshell, the term “well-formed” has to do with the structure of your content, and the term “valid” has to do with the content itself.  In this chapter, we are going to discuss how to create well-formed documents.